#include "CFGLoader.h"

#include <OgreConfigFile.h>


CFGLoader::CFGLoader()
{
    //ctor
}

CFGLoader::~CFGLoader()
{
    //dtor
}


/** @brief loadRessourceFile
  *
  * load a map of pair A=B in from a CFG file
  @param _filename	path for the file to open
  @return map with the parameters
  */
std::map<std::string, std::string>  CFGLoader::loadRessourceFile(std::string _filename)
{

    std::map<std::string, std::string> rmap;

    Ogre::String secName, paramName, paramValue;
    Ogre::ConfigFile cf;
    cf.load(_filename);

    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
    while (seci.hasMoreElements())
    {
        secName = seci.peekNextKey();
        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
        Ogre::ConfigFile::SettingsMultiMap::iterator i;
        for (i = settings->begin(); i != settings->end(); ++i)
        {
            paramName = i->first;
            paramValue = i->second;
            rmap.insert(std::pair<std::string,std::string>(paramName,paramValue));
        }
    }
    return rmap;
}

